﻿@model PagedList.IPagedList<CultuRAM.Models.Entity>

@{
    ViewBag.Title = "Index";
}

<h4><i class="icon-list" style="margin-top: 3px;"></i> Lista de Entidades</h4>


<table id="entities" class="table table-hover table-striped table-bordered" style="width:100%;">
    <tr style="font-size: 12px">
        <th>
            @Html.DisplayNameFor(model => model.First().Name)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.First().Phone)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.First().CellPhone)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.First().Responsible)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.First().ResponsibleContact)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.First().City.CityName)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.First().EntityType.EntityTypeName)
        </th>
        @*<th>Opções</th>*@
    </tr>

    @foreach (var item in Model) {
        <tr>
            <td>
                @Html.DisplayFor(modelItem => item.Name)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Phone)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.CellPhone)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Responsible)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.ResponsibleContact)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.City.CityName)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.EntityType.EntityTypeName)
            </td>
            @*<td>
                @Html.ActionLink("E", "Edit", new { id=item.EntityId })
                @Html.ActionLink("D", "Details", new { id=item.EntityId })
                @Html.ActionLink("D", "Delete", new { id=item.EntityId })
            </td>*@
        </tr>
    }

</table>
    
 @* Pagination *@
<div class="row-fluid pagination-botton">
    <div class="span6">
        <a id="btnAdd" href="@Url.Action("Create")" class = "btn btn-success"><i class="icon-plus icon-white"></i> Adicionar Entidade</a>
        <a id="btnEdit" href="@Url.Action("Edit")" class = "btn btn-warning"><i class="icon-pencil icon-white"></i> Editar Enditade</a>
        <a id="btnDel" href="@Url.Action("Delete")" class = "btn btn-danger"><i class="icon-remove icon-white"></i> Eliminar Entidade</a>    
    </div>
    <div class="span6" style="text-align: right; padding-right: 20px;">
        <div class="pagination" style="margin: 0;">
            <ul>
                @if (Model.HasPreviousPage)
                {
                    <li>@*@Html.ActionLink("«", "Index", new { page = 1 },  new { @class = "" })*@                       
                        @Html.Raw(@Html.ActionLink("replacetxt", "Index", new { page = 1  }, new { @class = "" })
		                    .ToHtmlString().Replace("replacetxt", "<i class=\"fa fa-angle-double-left\"></i>")) 
                    </li>
                    <li>@*@Html.ActionLink("<", "Index", new { page = Model.PageNumber - 1 },  new { @class = "" })*@
                        @Html.Raw(@Html.ActionLink("replacetxt", "Index", new { page = Model.PageNumber - 1  }, new { @class = "" })
		                    .ToHtmlString().Replace("replacetxt", "<i class=\"fa fa-angle-left\"></i>"))
                    </li>
                    <li class="">
                        <a href="#" data-original-title="" title="" class="">
                            Página <b> @(Model.PageCount < Model.PageNumber ? 0 : Model.PageNumber)</b> de <b> @Model.PageCount </b>
                        </a>
                    </li>                    
                }
                else
                {
                    <li class="disabled"><a href="#" data-original-title="" title="" class=""><i class="fa fa-angle-double-left"></i></a></li> 
                    <li class="disabled"><a href="#" data-original-title="" title="" class=""><i class="fa fa-angle-left"></i></a></li> 
                    <li class="">
                        <a href="#" data-original-title="" title="" class="disabled">
                            Página <b> @(Model.PageCount < Model.PageNumber ? 0 : Model.PageNumber)</b> de <b> @Model.PageCount </b>
                        </a>
                    </li>   
                }
                @if (Model.HasNextPage)
                {
                    <li>@*@Html.ActionLink(">", "Index", new { page = Model.PageNumber + 1 },  new { @class = "" })*@
                         @Html.Raw(@Html.ActionLink("replacetxt", "Index", new { page = Model.PageNumber + 1 }, new { @class = "" })
		                    .ToHtmlString().Replace("replacetxt", "<i class=\"fa fa-angle-right\"></i>"))
                    </li> 
                    <li>@*@Html.ActionLink("»", "Index", new { page = Model.PageCount },  new { @class = "" })*@
                        @Html.Raw(@Html.ActionLink("replacetxt", "Index", new { page = Model.PageCount }, new { @class = "" })
		                    .ToHtmlString().Replace("replacetxt", "<i class=\"fa fa-angle-double-right\"></i>"))
                    </li> 
                }
                else
                {
                    <li class="disabled"><a href="#" data-original-title="" title="" class="disabled"><i class="fa fa-angle-right"></i></a></li> 
                    <li class="disabled"><a href="#" data-original-title="" title="" class="disabled"><i class="fa fa-angle-double-right"></i></a></li>
                }
            </ul>
        </div>

    </div>
</div>





